extern "C" { 
    #include "apue.h" 
}   
#include <stdio.h>

#include <sys/stat.h>
//int chmod(const char *pathname, mode_t mode);


#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
//int stat(const char *pathname, struct stat *statbuf);

int main(int argc ,char** argv)
{    
    if(argc==1)
    {
        err_quit("pls input file path\n");
    }

    struct stat statbuf;

    if(0!=stat(argv[1], &statbuf))
    {
        err_quit("get file stat faild\n");
    }
    // 去除组的所有权限
    if(chmod(argv[1], statbuf.st_mode&=~(S_IRGRP|S_IWGRP|S_IXGRP))!=0)
    {
        err_quit("chmod  file mode faild\n");
    } 
    exit(0);

}

// reallin@ubuntu:~/work/pan/apue/study/3-6-5$ ll chmod.o
// -rw-rw-r-- 1 reallin reallin 188896 Nov 26 20:16 chmod.o
// reallin@ubuntu:~/work/pan/apue/study/3-6-5$ ./exe  chmod.o
// reallin@ubuntu:~/work/pan/apue/study/3-6-5$ ll chmod.o
// -rw----r-- 1 reallin reallin 188896 Nov 26 20:16 chmod.o